import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;


/**
 * This is a simple example of an HTTP Servlet.  It responds to the GET
 * method of the HTTP protocol.
 */
public class ResponseServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        PrintWriter out = response.getWriter();
       
        // then write the data of the response
        String username = request.getParameter("username");
       
        if ((username != null) && (username.length() > 0)) {
            out.println("Hello, " + username + "!");
        }
       
        String hobby = request.getParameter("hobby");
       
        if ((hobby != null) && (hobby.length() > 0)) {
            out.println("Your hobby is " + hobby + "!");
        }
        
        String enjoy = request.getParameter("enjoy");
        String howOften = request.getParameter("howOften");
        
        if ((enjoy != null) && (enjoy.length() > 0)) {
        	out.println("The reason you enjoy " + hobby + " " + howOften + " is because: \"" + enjoy + "\"");
        }
        
        String address=request.getParameter("address");
        if ((address != null) && (address.length() > 0)) {
        	out.println("Your mailing address is: " + address);
        }
    }
   
    public String getServletInfo() {
        return "The Response servlet says hello.";
    }
}